package com.huaxin.hxmoduleworkorder.models;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.huaxin.hxmoduleworkorder.common.enums.InspectionOrderPublishType;
import com.huaxin.hxmoduleworkorder.common.enums.InspectionOrderStatus;
import com.huaxin.hxmoduleworkorder.dto.request.InspectionOrderCustomerIdDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName(value = "inspection_order", autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class InspectionOrder extends BaseModel {
    @TableField(value = "title")
    @Schema(description = "工单标题", example = "月度客户用电安全巡检")
    private String title;

    @TableField(value = "description")
    @Schema(description = "工单描述", example = "对所有签约客户进行例行安全检查")
    private String description;

    @TableField(value = "status")
    @Schema(description = "状态：已发布/published/执行中/in_progress/已完成/completed/已取消/cancelled", example = "published")
    private InspectionOrderStatus status;

    @TableField(value = "publish_type")
    @Schema(description = "发布类型：自动/auto/手动/manual", example = "manual")
    private InspectionOrderPublishType publishType;

    @TableField(value = "execute_start_time")
    @Schema(description = "执行开始时间（可联系客户）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime executeStartTime;

    @TableField(value = "execute_end_time")
    @Schema(description = "执行截止时间（必须完成）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime executeEndTime;

    @TableField(value = "assigned_electrician_id")
    @Schema(description = "负责电工ID", example = "e1001")
    private String assignedElectricianId;

    @TableField(value = "assigned_electrician_name")
    @Schema(description = "负责电工名称", example = "张三")
    private String assignedElectricianName;

    @Schema(description = "涉及客户ID列表")
    @TableField(exist = false)
    private List<InspectionOrderCustomerIdDTO> customers;

    @TableField(value = "template_id")
    @Schema(description = "使用的巡查模板ID（可选）", example = "tpl_ins_001")
    private String templateId;

}

